<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link href="/static/css/base.css" rel="stylesheet">
    <link href="/static/css/login.css" rel="stylesheet">
    <link rel="stylesheet" href="/static/layui/assets/css/layui.css">
    <link rel="stylesheet" href="/static/layui/assets/css/admin.css">
    <link rel="stylesheet" href="/static/css/reveal.css">
    <link rel="stylesheet" href="/static/css/jquery-ui.css">
    <link rel="icon" href="/favicon.ico">
    <title>新增发票</title>
   	<style type="text/css">
   		.layer_notice{
   			background:#fdf8e4;
   			float:left;
   			height:23px;
   			width: 330px;
   			padding:10px;
   			overflow:hidden;
   			text-align: 2em;
   			color: #886a36;
   		}
   		#layer_a{
   			padding-left: 8%;
   		}
   	</style>
</head>
<body class="layui-view-body">
    <div class="layui-content">
        <div class="layui-row">
            <div class="layui-card">
                <div class="layui-card-header">电子报销</div>
                <form class="layui-form layui-card-body" action="add" id="formid" method="post">
                  <div class="layui-form-item">
                  	
                  	<div class="layui-form-item">
						<label class="layui-form-label">发票号码</label>
						<div class="layui-input-inline">
						  <input type="text" id="number1" name="number" placeholder="报销的电子发票号码" autocomplete="off"  class="layui-input" onclick="numbers()">
						</div>
						<button type="button" class="layui-btn layui-btn-normal" id="button1" onclick="buttonnumber()"><span class="layui-icon layui-icon-add">&#xe654;发票报销审核</span></button> 
						<button type="button" class="layui-btn layui-btn-warm  noon" onclick="buttonnoon()" style="display:none" ><span class="layui-icon layui-icon-refresh" >重新输入发票号码</span></button> 
					</div> 
					
					<div class="layui-form-item noon" style="display:none" >
						<label class="layui-form-label">发票代码</label>
						<div class="layui-input-inline">
							<input type="text"  name="code" id="code" placeholder="请输入发票代码" autocomplete="off" class="layui-input" ></div>
						
					</div>
					
					<div class="layui-form-item noon" style="display:none" >
						<label class="layui-form-label">报销人</label>
						<div class="layui-input-inline">
							<input type="text"  name="name" id="name" placeholder="请输入报销人姓名" autocomplete="off" class="layui-input" ></div>
						
					</div>
					
					<div class="layui-form-item noon" style="display:none" >
						<label class="layui-form-label">开票时间</label>
						<div class="layui-input-inline">
							<input type="text"  name="mindate" id="mindate" readonly="readonly"  placeholder="请选择时间" autocomplete="off" class="layui-input" ></div>
					</div>
					
					<div class="layui-form-item noon" style="display:none" >
						<label class="layui-form-label">金额</label>
						<div class="layui-input-inline">
							<input type="text"  name="money" id="money" placeholder="请输入金额" autocomplete="off" class="layui-input" onkeyup="value=value.replace(/[^\d]/g,'')"></div>
						<div class="layui-form-mid layui-word-aux"  >元</div>
					</div>
					
					<div id="layer_a" ><div class="layer_notice"  style="display:none"><i class="layui-icon layui-icon-face-surprised" style="padding-left: 3px;">&emsp;此发票账号已被报销，不可录入！</i></div></div>
                  </div>
                  <button type="button" class="layui-btn noon" id="but" style="margin-left: 10%;display:none" onclick="sumbitone()">提交电子发票</button>
                </form>  
            </div>
        </div>
    </div>
    <script src="/static/layui/assets/layui.all.js"></script>
    <script type="text/javascript" src="/static/js/index.js"></script>
	<script src="/static/layui/assets/layui.js"></script>
    <script src="/static/layui/index.js" data-main="home"></script>
    <script type="text/javascript" src="/static/js/eim.js"></script>
    <script type="text/javascript" src="/static/js/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" src="/static/js/jquery.reveal.js"></script>
    <script src="http://www.jq22.com/js/jq.js"></script>
</body>
    <script>
    function numbers(){
    	$("#layer_a").hide(); 
    }
      function buttonnumber(){
    	  var a=$("input[name='number']").val();
    	  if(a==""){
    		  layer.msg('发票号码不能为空');
    	  }else{
    		  $.post('numberxy?number='+a, function(data){
    	  			if(! data){
    	  				$("#layer_a").show();
    	  				layer.open({
    	  				  type: 1,
    	  				  shade: false,
    	  				  title: false, //不显示标题
    	  				  content: $('.layer_notice'), //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
    	  				});
    	  			}else {
    	  				$("#number1").attr("disabled", true);
    	  				$("#number1").addClass("layui-btn layui-btn-disabled");
    	  				$("#button1").removeClass("layui-btn layui-btn-normal").addClass("layui-btn layui-btn-disabled");
    	  				$(".noon").show();
    	  			}
    	  		});
    	  }
      };
      function buttonnoon(){
    	  $("#number1").removeAttr("disabled");
    	  $("#number1").removeClass("layui-btn layui-btn-disabled");
    	  $("#button1").removeClass("layui-btn layui-btn-disabled").addClass("layui-btn layui-btn-normal");
    	  $(".noon").hide();
    	  $("#code").val("");
    	  $("#name").val("");
    	  $("#mindate").val("");
    	  $("#money").val("");
      }
      function sumbitone(){
    	  var a=$("input[name='number']").val();
    	  $.post('numberxy?number='+a, function(data){
    		  if(! data){
    			  layer.msg('提交错误！报销失败，因为在报销期间，其他平台已抢先报销！');
    			}else {
    				var a1=$("input[name='mindate']").val();
    				var a2=$("input[name='money']").val();
    				var a3=$("input[name='name']").val();
    				var a4=$("input[name='code']").val();
    				if(a1!=""&&a2!=""&&a3!=""&&a4!=""){
    					$("#number1").attr("disabled", false);
    					$("#formid").submit()
    				}else{
    					layer.msg('请填写完所有信息以后提交！');
    				}
    			}
    	  });
      }
      layui.use('laydate', function(){
    	  var laydate = layui.laydate;
    	  
    	  //执行一个laydate实例
    	  laydate.render({
    	    elem: '#mindate' //指定元素
    	  });
    	});
    </script>
</html>